package Model

import "time"

type Employee struct {
	Empid          int
	Name           string
	Address        string
	//员工分类
	Classification PaymentClassification
	//工资条
	Schedule       PaymentSchedule
	//支付方式
	PaymentMethod  PaymentMethod
	Affiliation    Affiliation
}

//创建对象
func NewEmployee(empid int, name, address string) *Employee {
	return &Employee{Empid: empid, Name: name, Address: address}
}

//设置员工的各项信息
func (e *Employee) SetEmpid(empid int) {
	e.Empid = empid
}

func (e *Employee) SetSchedule(ps PaymentSchedule) {
	e.Schedule = ps
}

func (e *Employee) SetMethod(pm PaymentMethod) {
	e.PaymentMethod = pm
}

func (e *Employee) SetClassification(pc PaymentClassification) {
	e.Classification = pc
}

func (e *Employee) SetName(name string) {
	e.Name = name
}

func (e *Employee) SetAddress(address string) {
	e.Address = address
}

func (e *Employee) SetAffiliation(af Affiliation) {
	e.Affiliation = af
}


//得到员工的各项信息
func (e *Employee) GetSchedule() PaymentSchedule {
	return e.Schedule
}

func (e *Employee) GetClassification() PaymentClassification {
	return e.Classification
}

func (e *Employee) GetName() string {
	return e.Name
}

func (e *Employee) GetEmpid() int {
	return e.Empid
}

func (e *Employee) GetAddress() string {
	return e.Address
}

func (e *Employee) GetMethod() PaymentMethod {
	return e.PaymentMethod
}

func (e *Employee) GetAffiliation() Affiliation {
	return e.Affiliation
}

func (e *Employee) IsPayDate(date time.Time) bool {
	return e.Schedule.IsPayData(date)
}

func (e *Employee) GetSalaryStartDate(SalaryEndDate time.Time) time.Time {
	return e.Schedule.GetSalaryStartDate(SalaryEndDate)
}

func (e *Employee) Payday(sc Salarycheck) {
	//计算总工资
	grossSalary := e.Classification.CalculatePay(sc)
	//计算扣除
	deductions := e.Affiliation.CalculateDeductions(sc)
	//净工资
	NetSalary := grossSalary - deductions
	sc.SetGrossSalary(grossSalary)
	sc.SetNetSalary(NetSalary)
	sc.SetDeductions(deductions)
	e.PaymentMethod.Pay(sc)
}
